package com.sz.biz.pay.account.service.impl;

import com.sz.biz.common.constants.ShortName;
import com.sz.biz.pay.account.entity.BankInfo;
import com.sz.biz.pay.account.service.BankInfoService;
import com.sz.common.base.dao.ParamData;
import com.sz.common.base.dto.QResultDto;
import com.sz.common.base.dto.QueryParams;
import com.sz.common.base.service.AbstractService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Function: 查询大小额联行号银行代码列表 <br>
 * Author: siqishangshu <br>
 * Date: 2017-10-27 16:58:00
 */
@Service
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public class BankInfoServiceImpl extends AbstractService implements BankInfoService {

    @Override
    public BankInfo select(String id) {
        return (BankInfo) dao.findForObject(getMapperNamespace()+ ShortName.SELECT_BY_ID,id);
    }

    @Override
    public List<BankInfo> selectList(List ids) {
        return null;
    }

    @Override
    public List<BankInfo> selectAll() {
        return null;
    }

    @Override
    public QResultDto selectList(QueryParams param) {
        return null;
    }

    @Override
    public int count(QueryParams param) {
        return 0;
    }

    @Override
    public int countAll() {
        return 0;
    }

    /**
     * 根据条件查询支行列表
     * @param q
     * @param pageIndex
     * @param pageSize
     * @param sort
     * @param isAsc
     * @param language
     * @return
     */
    @Override
    public QResultDto findBankName(String q, int pageIndex, int pageSize, String sort, boolean isAsc, String language,String bankClsCode) {
        QueryParams queryParams = new QueryParams(pageSize, pageIndex, q, sort, isAsc, language);
        queryParams.put("bankClsCode",bankClsCode);
        queryParams.put("q", q);
        ParamData pd = this.convertQueryParams(queryParams);

        List<BankInfo> bankInfos = dao.findForList(getSqlName("findBankListPage"),pd,BankInfo.class);

        QResultDto qResultDto = new QResultDto();
        qResultDto.setData(bankInfos);
        qResultDto.setPagination(pd.getPagination());
        return qResultDto;
    }


    @Override
    protected String getMapperNamespace() {
        return "com.sz.biz.pay.account.BankInfoMapper";
    }
}
